package com.lxk.controller;

import com.lxk.util.MyFileUtil;
import com.lxk.vo.result.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.Map;

/**
 * @author JohnSoybean
 * @create 2020/6/17 15:42
 * @description 文件传输相关控制器
 */
@RestController
@RequestMapping("/upload")
public class FileController {

    /**
     * 上传单张图片
     * @param file
     * @return
     */
    @PostMapping("/img")
    public Result<String> uploadSingle(MultipartFile file) {
        String url = MyFileUtil.uploadImage(file);
        return Result.success(url);
    }

    /**
     * 上传普通文件
     * @param file
     * @return
     */
    @PostMapping("/common")
    public Result<String> uploadSingleCommon(MultipartFile file) {
        String url = MyFileUtil.uploadFile(file);
        return Result.success(url);
    }
}
